

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>The meta module &mdash; pyamp v1.2 documentation</title>
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '1.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="top" title="pyamp v1.2 documentation" href="../index.html" />
    <link rel="up" title="The logging module" href="mod_pyamp_logging.html" />
    <link rel="next" title="The patterns module" href="mod_pyamp_patterns.html" />
    <link rel="prev" title="The loggable module" href="pyamp_logging_loggable.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="mod_pyamp_patterns.html" title="The patterns module"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="pyamp_logging_loggable.html" title="The loggable module"
             accesskey="P">previous</a> |</li>
        <li><a href="../index.html">pyamp v1.2 documentation</a> &raquo;</li>
          <li><a href="mod_pyamp.html" >The pyamp module</a> &raquo;</li>
          <li><a href="mod_pyamp_logging.html" accesskey="U">The logging module</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-pyamp.logging.meta">
<span id="the-meta-module"></span><h1>The meta module<a class="headerlink" href="#module-pyamp.logging.meta" title="Permalink to this headline">¶</a></h1>
<p>The meta module contains the LoggerMeta, and FunctionLoggerMeta classes.</p>
<p>These classes provide the ability for create a class which will have the
ability to be logged, or to wrap certain class functions with logging messages
to indicate when the function was entered and exited.</p>
<div class="section" id="the-loglevel-class">
<h2>The LogLevel class<a class="headerlink" href="#the-loglevel-class" title="Permalink to this headline">¶</a></h2>
<p class="graphviz">
<img src="../_images/inheritance-96f836cb80df9307552cf82c9536d495aed9ab2f.png" alt="Inheritance diagram of pyamp.logging.meta.LogLevel" usemap="#inheritanceb0155d4ab1" class="inheritance"/>
<map id="inheritanceb0155d4ab1" name="inheritanceb0155d4ab1">
<area shape="rect" href="pyamp_logging_logger.html#pyamp.logging.logger.LogLevel" title="pyamp.logging.logger.LogLevel" alt="" coords="5,7,224,33"/>
</map>
</p>
<dl class="class">
<dt id="pyamp.logging.meta.LogLevel">
<em class="property">class </em><tt class="descclassname">pyamp.logging.meta.</tt><tt class="descname">LogLevel</tt><a class="headerlink" href="#pyamp.logging.meta.LogLevel" title="Permalink to this definition">¶</a></dt>
<dd><p>The LogLevel class contains definitions of all of the various log
levels that can be used for logging messages. These levels are designed
to make it easier to parse the output of a system to find different types
of issues that were encountered at runtime.</p>
<ul class="simple">
<li><strong>DEBUG</strong> &#8211; The debugging log level. Has a value of 10.</li>
<li><strong>INFO</strong> &#8211; The information log level. Has a value of 20.</li>
<li><strong>WARN</strong> &#8211; The warning log level. Has a value of 30.</li>
<li><strong>WARNING</strong> &#8211; The warning log level. Has a value of 30.</li>
<li><strong>ERROR</strong> &#8211; The error log level. Has a value of 40.</li>
<li><strong>CRITICAL</strong> &#8211; The critical log level. Has a value of 50.</li>
<li><strong>FATAL</strong> &#8211; The fatal log level. Has a value of 50.</li>
</ul>
</dd></dl>

</div>
<div class="section" id="the-functionloggermeta-class">
<h2>The FunctionLoggerMeta class<a class="headerlink" href="#the-functionloggermeta-class" title="Permalink to this headline">¶</a></h2>
<p class="graphviz">
<img src="../_images/inheritance-a81a1419439beb07148393451a6a517d9fa22b46.png" alt="Inheritance diagram of pyamp.logging.meta.FunctionLoggerMeta" usemap="#inheritance4d12d41e11" class="inheritance"/>
<map id="inheritance4d12d41e11" name="inheritance4d12d41e11">
<area shape="rect" href="#pyamp.logging.meta.LoggerMeta" title="pyamp.logging.meta.LoggerMeta" alt="" coords="32,7,264,33"/>
<area shape="rect" href="#pyamp.logging.meta.FunctionLoggerMeta" title="pyamp.logging.meta.FunctionLoggerMeta" alt="" coords="5,84,291,111"/>
</map>
</p>
<dl class="class">
<dt id="pyamp.logging.meta.FunctionLoggerMeta">
<em class="property">class </em><tt class="descclassname">pyamp.logging.meta.</tt><tt class="descname">FunctionLoggerMeta</tt><a class="reference internal" href="../_modules/pyamp/logging/meta.html#FunctionLoggerMeta"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyamp.logging.meta.FunctionLoggerMeta" title="Permalink to this definition">¶</a></dt>
<dd><p>The FunctionLoggerMeta class is a metaclass that provides the ability
to log specific functions of a class. This metaclass uses the
<a class="reference internal" href="#pyamp.logging.meta.Logger" title="pyamp.logging.meta.Logger"><tt class="xref py py-class docutils literal"><span class="pre">Logger</span></tt></a> object (as created by the <a class="reference internal" href="#pyamp.logging.meta.LoggerMeta" title="pyamp.logging.meta.LoggerMeta"><tt class="xref py py-class docutils literal"><span class="pre">LoggerMeta</span></tt></a> class) to
print debug statements as functions of a class are entered and exited.</p>
<dl class="docutils">
<dt>The following types of functions will NOT be logged:</dt>
<dd><ul class="first last simple">
<li>Builtin functions (i.e., the function name ends with &#8216;__&#8217;)</li>
<li>Functions that are decorated with the <tt class="xref py py-func docutils literal"><span class="pre">doNotLog()</span></tt> function</li>
</ul>
</dd>
</dl>
<p>All other functions will log a DEBUG message when the function is entered
and when the function is exited. This provides an easy way to toggle the
ability to view the scope of functions during the runtime of a system.</p>
<p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">class</span> <span class="nc">Example</span><span class="p">:</span>
    <span class="n">__metaclass__</span> <span class="o">=</span> <span class="n">FunctionLoggerMeta</span>

    <span class="k">def</span> <span class="nf">test</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">print</span> <span class="s">&quot;This is a test&quot;</span>


<span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">&#39;__main__&#39;</span><span class="p">:</span>
    <span class="n">example</span> <span class="o">=</span> <span class="n">Example</span><span class="p">()</span>

    <span class="c"># Prints:</span>
    <span class="c">#    [DEBUG]: Entering test</span>
    <span class="c">#    This is a test</span>
    <span class="c">#    [DEBUG]: Exiting test</span>
    <span class="n">example</span><span class="o">.</span><span class="n">test</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="the-logger-class">
<h2>The Logger class<a class="headerlink" href="#the-logger-class" title="Permalink to this headline">¶</a></h2>
<p class="graphviz">
<img src="../_images/inheritance-17c19675f3220e7744703ca615c05037e898151b.png" alt="Inheritance diagram of pyamp.logging.meta.Logger" usemap="#inheritanced244c42900" class="inheritance"/>
<map id="inheritanced244c42900" name="inheritanced244c42900">
<area shape="rect" href="pyamp_logging_logger.html#pyamp.logging.logger.Logger" title="pyamp.logging.logger.Logger" alt="" coords="5,161,211,188"/>
</map>
</p>
<dl class="class">
<dt id="pyamp.logging.meta.Logger">
<em class="property">class </em><tt class="descclassname">pyamp.logging.meta.</tt><tt class="descname">Logger</tt><big>(</big><em>name=None</em>, <em>color=0</em>, <em>prefix=&lt;pyamp.logging.prefix.Prefix instance at 0x957d32c&gt;</em>, <em>logLevel=30</em>, <em>debugLevel=0</em>, <em>handler=&lt;logging.StreamHandler instance at 0x957af2c&gt;</em><big>)</big><a class="headerlink" href="#pyamp.logging.meta.Logger" title="Permalink to this definition">¶</a></dt>
<dd><p>The Logger class provides the ability to log various types
of messages to a specific stream, and formats the messages using given
<a class="reference internal" href="#pyamp.logging.meta.Prefix" title="pyamp.logging.meta.Prefix"><tt class="xref py py-class docutils literal"><span class="pre">Prefix</span></tt></a> objects.</p>
<p>The Logger class will log each <a class="reference internal" href="#pyamp.logging.meta.LogLevel" title="pyamp.logging.meta.LogLevel"><tt class="xref py py-class docutils literal"><span class="pre">LogLevel</span></tt></a> with a colored
prefix indicating the name of the log level. Logged messages are only
displayed in the event that the <a class="reference internal" href="#pyamp.logging.meta.LogLevel" title="pyamp.logging.meta.LogLevel"><tt class="xref py py-class docutils literal"><span class="pre">LogLevel</span></tt></a> at which they are
logged is greater than or equal to the current <a class="reference internal" href="#pyamp.logging.meta.LogLevel" title="pyamp.logging.meta.LogLevel"><tt class="xref py py-class docutils literal"><span class="pre">LogLevel</span></tt></a> of the
Logger which is logging the message. Each <tt class="xref py py-class docutils literal"><span class="pre">LogLevel.DEBUG</span></tt>
message can also have an optional debug level specified, which will allow
that message to be displayed so long as the specified debug level is less
than or equal to the configured debug level of the Logger object.</p>
<p>Each Logger object can be named, and colored, which means that
any message logged using that object will be displayed with a prefix
indicating the name (and displayed in the specified color) of the object
which logged the message.</p>
<p>Logger objects can be given a chain of <a class="reference internal" href="#pyamp.logging.meta.Prefix" title="pyamp.logging.meta.Prefix"><tt class="xref py py-class docutils literal"><span class="pre">Prefix</span></tt></a> objects.
Any message logged using that Logger object will then have a
series of prefixes added to the front of the message.</p>
<p>Logger objects can also have a handler specified, which specifies
the type of stream which will be handled by this Logger. For
example, to output to the console a value of <a class="reference external" href="http://docs.python.org/library/logging.handlers.html#logging.StreamHandler" title="(in Python v2.7)"><tt class="docutils literal"><span class="pre">logging.StreamHandler</span></tt></a>
could be specified, whereas a value of <a class="reference external" href="http://docs.python.org/library/logging.handlers.html#logging.FileHandler" title="(in Python v2.7)"><tt class="docutils literal"><span class="pre">logging.FileHandler</span></tt></a> could
be specified to log to a specific file.</p>
<p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># Create a Logger with the name &#39;Example1&#39;</span>
<span class="n">logger</span> <span class="o">=</span> <span class="n">Logger</span><span class="p">(</span><span class="s">&quot;Example1&quot;</span><span class="p">)</span>
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&quot;Information message&quot;</span><span class="p">)</span>

<span class="c"># Create a Logger with the name &#39;Example2&#39;, a foreground</span>
<span class="c"># color of Blue, and logs DEBUG messages that have a debug</span>
<span class="c"># level less than or equal to 10.</span>
<span class="n">logger</span> <span class="o">=</span> <span class="n">Logger</span><span class="p">(</span><span class="s">&quot;Example2&quot;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="n">Colors</span><span class="o">.</span><span class="n">Foreground</span><span class="o">.</span><span class="n">Blue</span><span class="p">,</span>
                <span class="n">logLevel</span><span class="o">=</span><span class="n">LogLevel</span><span class="o">.</span><span class="n">DEBUG</span><span class="p">,</span> <span class="n">debugLevel</span><span class="o">=</span><span class="mi">10</span><span class="p">)</span>
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&quot;This message is displayed&quot;</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&quot;This message is not displayed&quot;</span><span class="p">,</span> <span class="mi">11</span><span class="p">)</span>

<span class="c"># Create a Logger with the name &#39;Example3&#39; that only displays</span>
<span class="c"># ERROR messages</span>
<span class="n">logger</span> <span class="o">=</span> <span class="n">Logger</span><span class="p">(</span><span class="s">&quot;Example3&quot;</span><span class="p">,</span> <span class="n">logLevel</span><span class="o">=</span><span class="n">LogLevel</span><span class="o">.</span><span class="n">ERROR</span><span class="p">)</span>
<span class="n">logger</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="s">&quot;This would not be displayed&quot;</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li>name &#8211; The name of the Logger</li>
<li>color &#8211; The color to use for this Logger</li>
<li>prefix &#8211; The <a class="reference internal" href="#pyamp.logging.meta.Prefix" title="pyamp.logging.meta.Prefix"><tt class="xref py py-class docutils literal"><span class="pre">Prefix</span></tt></a> chain to use for this Logger</li>
<li>logLevel &#8211; The log level to use for this Logger</li>
<li>debugLevel &#8211; The debug level</li>
<li>handler &#8211; The handler to use for this Logger</li>
</ul>
<dl class="method">
<dt id="pyamp.logging.meta.Logger.critical">
<tt class="descname">critical</tt><big>(</big><em>message</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#pyamp.logging.meta.Logger.critical" title="Permalink to this definition">¶</a></dt>
<dd><p>Log a critical message.</p>
<ul class="simple">
<li>message &#8211; The message to log</li>
<li>args &#8211; The arguments</li>
<li>kwargs &#8211; The keyword arguments</li>
</ul>
</dd></dl>

<dl class="method">
<dt id="pyamp.logging.meta.Logger.debug">
<tt class="descname">debug</tt><big>(</big><em>message</em>, <em>level=0</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#pyamp.logging.meta.Logger.debug" title="Permalink to this definition">¶</a></dt>
<dd><p>Log a debug message.</p>
<ul class="simple">
<li>message &#8211; The message to log</li>
<li>level &#8211; The debug level</li>
<li>args &#8211; The arguments</li>
<li>kwargs &#8211; The keyword arguments</li>
</ul>
</dd></dl>

<dl class="method">
<dt id="pyamp.logging.meta.Logger.error">
<tt class="descname">error</tt><big>(</big><em>message</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#pyamp.logging.meta.Logger.error" title="Permalink to this definition">¶</a></dt>
<dd><p>Log an error message.</p>
<ul class="simple">
<li>message &#8211; The message to log</li>
<li>args &#8211; The arguments</li>
<li>kwargs &#8211; The keyword arguments</li>
</ul>
</dd></dl>

<dl class="method">
<dt id="pyamp.logging.meta.Logger.fatal">
<tt class="descname">fatal</tt><big>(</big><em>message</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#pyamp.logging.meta.Logger.fatal" title="Permalink to this definition">¶</a></dt>
<dd><p>Log a fatal message.</p>
<ul class="simple">
<li>message &#8211; The message to log</li>
<li>args &#8211; The arguments</li>
<li>kwargs &#8211; The keyword arguments</li>
</ul>
</dd></dl>

<dl class="method">
<dt id="pyamp.logging.meta.Logger.info">
<tt class="descname">info</tt><big>(</big><em>message</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#pyamp.logging.meta.Logger.info" title="Permalink to this definition">¶</a></dt>
<dd><p>Log an info message.</p>
<ul class="simple">
<li>message &#8211; The message to log</li>
<li>args &#8211; The arguments</li>
<li>kwargs &#8211; The keyword arguments</li>
</ul>
</dd></dl>

<dl class="method">
<dt id="pyamp.logging.meta.Logger.log">
<tt class="descname">log</tt><big>(</big><em>logLevel</em>, <em>message</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#pyamp.logging.meta.Logger.log" title="Permalink to this definition">¶</a></dt>
<dd><p>Log a message at the given log level.</p>
<ul class="simple">
<li>logLevel &#8211; The level at which to log</li>
<li>message &#8211; The message to log</li>
<li>args &#8211; The arguments</li>
<li>kwargs &#8211; The keyword arguments</li>
</ul>
</dd></dl>

<dl class="method">
<dt id="pyamp.logging.meta.Logger.setName">
<tt class="descname">setName</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#pyamp.logging.meta.Logger.setName" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the name for this logger.</p>
<ul class="simple">
<li>name &#8211; The name</li>
</ul>
</dd></dl>

<dl class="method">
<dt id="pyamp.logging.meta.Logger.setPrefix">
<tt class="descname">setPrefix</tt><big>(</big><em>prefix</em><big>)</big><a class="headerlink" href="#pyamp.logging.meta.Logger.setPrefix" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the prefix for this logger.</p>
<ul class="simple">
<li>prefix &#8211; The prefix</li>
</ul>
</dd></dl>

<dl class="method">
<dt id="pyamp.logging.meta.Logger.warn">
<tt class="descname">warn</tt><big>(</big><em>message</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#pyamp.logging.meta.Logger.warn" title="Permalink to this definition">¶</a></dt>
<dd><p>Log a warning message.</p>
<ul class="simple">
<li>message &#8211; The message to log</li>
<li>args &#8211; The arguments</li>
<li>kwargs &#8211; The keyword arguments</li>
</ul>
</dd></dl>

<dl class="method">
<dt id="pyamp.logging.meta.Logger.warning">
<tt class="descname">warning</tt><big>(</big><em>message</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#pyamp.logging.meta.Logger.warning" title="Permalink to this definition">¶</a></dt>
<dd><p>Log a warning message.</p>
<ul class="simple">
<li>message &#8211; The message to log</li>
<li>args &#8211; The arguments</li>
<li>kwargs &#8211; The keyword arguments</li>
</ul>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="the-prefix-class">
<h2>The Prefix class<a class="headerlink" href="#the-prefix-class" title="Permalink to this headline">¶</a></h2>
<p class="graphviz">
<img src="../_images/inheritance-df798ff592858a9c7fc5c846b7761ffe47b9eda3.png" alt="Inheritance diagram of pyamp.logging.meta.Prefix" usemap="#inheritance84a2aa5cc6" class="inheritance"/>
<map id="inheritance84a2aa5cc6" name="inheritance84a2aa5cc6">
<area shape="rect" href="pyamp_logging_prefix.html#pyamp.logging.prefix.Prefix" title="pyamp.logging.prefix.Prefix" alt="" coords="5,7,197,33"/>
</map>
</p>
<dl class="class">
<dt id="pyamp.logging.meta.Prefix">
<em class="property">class </em><tt class="descclassname">pyamp.logging.meta.</tt><tt class="descname">Prefix</tt><big>(</big><em>text=None</em>, <em>color=0</em>, <em>prefix=None</em><big>)</big><a class="headerlink" href="#pyamp.logging.meta.Prefix" title="Permalink to this definition">¶</a></dt>
<dd><p>The Prefix class provides the ability to add chain of prefixes to a
message. A Prefix contains text which is printed in square brackets
before the given message. The following shows an example of the a
Prefix for the string &#8220;DEBUG&#8221;.</p>
<p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">prefix</span> <span class="o">=</span> <span class="n">Prefix</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="s">&quot;DEBUG&quot;</span><span class="p">)</span>

<span class="c"># Prints: [DEBUG]: This is the message</span>
<span class="n">prefix</span><span class="o">.</span><span class="n">apply</span><span class="p">(</span><span class="s">&quot;This is the message&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>A Prefix can be colored, and it can contain other prefixes which are
appended to the message before adding the current Prefix.</p>
<p>An example of multiple prefixes:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">debugPrefix</span> <span class="o">=</span> <span class="n">Prefix</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="s">&quot;DEBUG&quot;</span><span class="p">)</span>
<span class="n">examplePrefix</span> <span class="o">=</span> <span class="n">Prefix</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="s">&quot;example&quot;</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="n">debugPrefix</span><span class="p">)</span>
<span class="n">datePrefix</span> <span class="o">=</span> <span class="n">Prefix</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="s">&quot;03/11/2012&quot;</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="n">examplePrefix</span><span class="p">)</span>

<span class="c"># Prints: [DEBUG]: [example]: [03/11/2012]: This is the message</span>
<span class="n">datePrefix</span><span class="o">.</span><span class="n">apply</span><span class="p">(</span><span class="s">&quot;This is the message&quot;</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li>text &#8211; The text to display in the Prefix</li>
<li>color &#8211; The color in which the Prefix will be displayed</li>
<li>prefix &#8211; The next Prefix in the chain</li>
</ul>
<dl class="method">
<dt id="pyamp.logging.meta.Prefix.apply">
<tt class="descname">apply</tt><big>(</big><em>message</em>, <em>useColors=False</em><big>)</big><a class="headerlink" href="#pyamp.logging.meta.Prefix.apply" title="Permalink to this definition">¶</a></dt>
<dd><p>Apply the chain of Prefixes to the given message.</p>
<ul class="simple">
<li>message &#8211; The message to apply the Prefix chain to</li>
<li>useColors &#8211; True to use colors, False otherwise</li>
</ul>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="the-loggermeta-class">
<h2>The LoggerMeta class<a class="headerlink" href="#the-loggermeta-class" title="Permalink to this headline">¶</a></h2>
<p class="graphviz">
<img src="../_images/inheritance-6683233265f419bacb6f9703a9ff221410ac2862.png" alt="Inheritance diagram of pyamp.logging.meta.LoggerMeta" usemap="#inheritance6c277a0dc0" class="inheritance"/>
<map id="inheritance6c277a0dc0" name="inheritance6c277a0dc0">
<area shape="rect" href="#pyamp.logging.meta.LoggerMeta" title="pyamp.logging.meta.LoggerMeta" alt="" coords="5,7,237,33"/>
</map>
</p>
<dl class="class">
<dt id="pyamp.logging.meta.LoggerMeta">
<em class="property">class </em><tt class="descclassname">pyamp.logging.meta.</tt><tt class="descname">LoggerMeta</tt><a class="reference internal" href="../_modules/pyamp/logging/meta.html#LoggerMeta"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyamp.logging.meta.LoggerMeta" title="Permalink to this definition">¶</a></dt>
<dd><p>The LoggerMeta is a metaclass that provides the ability to create a
<a class="reference internal" href="#pyamp.logging.meta.Logger" title="pyamp.logging.meta.Logger"><tt class="xref py py-class docutils literal"><span class="pre">Logger</span></tt></a> for a given class. The class has the ability to set the
following static class properties.</p>
<ul class="simple">
<li><em>logLevel</em> &#8211; Set log level for the logger</li>
<li><em>logPrefix</em> &#8211; Set the log prefix for the logger</li>
</ul>
<p>Any classes that use LoggerMeta as their metaclass will have a &#8216;logger&#8217;
property created, which will be a <a class="reference internal" href="#pyamp.logging.meta.Logger" title="pyamp.logging.meta.Logger"><tt class="xref py py-class docutils literal"><span class="pre">Logger</span></tt></a> object with the preset
logLevel, and logPrefix.</p>
<p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">class</span> <span class="nc">Example</span><span class="p">:</span>
    <span class="n">__metaclass__</span> <span class="o">=</span> <span class="n">LoggerMeta</span>
    <span class="n">logLevel</span> <span class="o">=</span> <span class="n">LogLevel</span><span class="o">.</span><span class="n">INFO</span>
    <span class="n">logPrefix</span> <span class="o">=</span> <span class="n">Prefix</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="s">&quot;TestPrefix&quot;</span><span class="p">)</span>

<span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">&#39;__main__&#39;</span><span class="p">:</span>
    <span class="n">example</span> <span class="o">=</span> <span class="n">Example</span><span class="p">()</span>

    <span class="c"># Prints: [Example]: [TestPrefix]: This is an information message</span>
    <span class="n">example</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&quot;This is an information message&quot;</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">The meta module</a><ul>
<li><a class="reference internal" href="#the-loglevel-class">The LogLevel class</a></li>
<li><a class="reference internal" href="#the-functionloggermeta-class">The FunctionLoggerMeta class</a></li>
<li><a class="reference internal" href="#the-logger-class">The Logger class</a></li>
<li><a class="reference internal" href="#the-prefix-class">The Prefix class</a></li>
<li><a class="reference internal" href="#the-loggermeta-class">The LoggerMeta class</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="pyamp_logging_loggable.html"
                        title="previous chapter">The loggable module</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="mod_pyamp_patterns.html"
                        title="next chapter">The patterns module</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/_generated/pyamp_logging_meta.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" size="18" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="mod_pyamp_patterns.html" title="The patterns module"
             >next</a> |</li>
        <li class="right" >
          <a href="pyamp_logging_loggable.html" title="The loggable module"
             >previous</a> |</li>
        <li><a href="../index.html">pyamp v1.2 documentation</a> &raquo;</li>
          <li><a href="mod_pyamp.html" >The pyamp module</a> &raquo;</li>
          <li><a href="mod_pyamp_logging.html" >The logging module</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2012, Brett Ponsler.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.1.
    </div>
  </body>
</html>